//
//  LSZFansTableViewCell.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/31.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZFansTableViewCell.h"

@implementation LSZFansTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:80 :5];
        self.imageViewFans = [[UIImageView alloc]init];
        self.imageViewFans.frame = CGRectMake(15, 10, height-20, height-20);
        [self.imageViewFans.layer setMasksToBounds:YES];
        [self.imageViewFans.layer setCornerRadius:self.imageViewFans.frame.size.height/2];
        [self addSubview:self.imageViewFans];

        CGFloat heightName = [LSZSpecialPackaging initWithReturnsthesizeOf:20 :2];
        self.labelName = [[UILabel alloc]init];
        self.labelName.frame = CGRectMake(CGRectGetMaxX(self.imageViewFans.frame)+10, CGRectGetMinY(self.imageViewFans.frame)+10, ScreenWidth/2, heightName);
        self.labelName.textColor = titleColorLSZ;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelName font:13.5];
        [self addSubview:self.labelName];

        CGFloat heightAddress = [LSZSpecialPackaging initWithReturnsthesizeOf:16 :2];
        self.labelAddress = [[UILabel alloc]init];
        self.labelAddress.frame = CGRectMake(CGRectGetMaxX(self.imageViewFans.frame)+10, CGRectGetMaxY(self.imageViewFans.frame)-heightAddress-10, ScreenWidth/2, heightAddress);
        self.labelAddress.textColor = lightColor;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelAddress font:12];
        [self addSubview:self.labelAddress];

        CGFloat heightFocusOn = [LSZSpecialPackaging initWithReturnsthesizeOf:30 :5];
        self.butFocusOn = [[UIButton alloc]init];
        self.butFocusOn.frame = CGRectMake(ScreenWidth-60, (height-heightFocusOn)/2, 50, heightFocusOn);
        self.butFocusOn.backgroundColor = redUIColor;
        [self.butFocusOn.layer setMasksToBounds:YES];
        [self.butFocusOn.layer setCornerRadius:4];
        [self.butFocusOn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.butFocusOn setTitle:@"+关注" forState:UIControlStateNormal];
        [LSZSpecialPackaging setLabelAdaptiveSize:self.butFocusOn.titleLabel font:13.5];
        [self addSubview:self.butFocusOn];
    }
    return self;
}
-(void)setAttentionFansMg:(LSZAttentionFansMg *)attentionFansMg
{
    [self.imageViewFans sd_setImageWithURL:[NSURL URLWithString:attentionFansMg.avatar] placeholderImage:[UIImage imageNamed:@""]];
    self.labelName.text = attentionFansMg.username;
    self.labelAddress.text = attentionFansMg.location;
    if([attentionFansMg.is_follow isEqualToString:@"0"]){
        self.butFocusOn.backgroundColor = redUIColor;
        [self.butFocusOn setTitle:@"+关注" forState:UIControlStateNormal];
        self.butFocusOn.userInteractionEnabled = YES;
    }else if ([attentionFansMg.is_follow isEqualToString:@"2"]){
        self.butFocusOn.hidden = YES;
    }
    else{
        [self.butFocusOn setTitle:@"已关注" forState:UIControlStateNormal];
        self.butFocusOn.backgroundColor =  partialShallow;
        self.butFocusOn.userInteractionEnabled = NO;
    }
}
@end
